<template>
  <view class="container">
    <z-paging-swiper>
      <view slot="top">
        <u-navbar height="50" title="职位管理" title-size="36" title-color="#333"></u-navbar>
        <view class="tabsView">
          <u-tabs-swiper
            ref="uTabs"
            font-size="32"
            :list="tabsList"
            :current="current"
            @change="tabsChange"
            :is-scroll="false"
            :show-bar="false"
            active-color="#10A28F"
            swiper-width="750rpx"
          >
          </u-tabs-swiper>
        </view>
        <u-gap height="20" bg-color="#F0F1F2"></u-gap>
      </view>
      <swiper
        class="swiperView"
        :current="scurrent"
        @transition="transition"
        @animationfinish="animationfinish"
      >
        <swiper-item v-for="(sitem, sindex) in tabsList" class="swiperItem" :key="sindex">
          <z-paging
            ref="paging"
            v-model="itemList[sindex]"
            @query="queryList"
            :fixed="true"
            :auto="false"
            :empty-view-img="`${getImageUrl('empty.png')} `"
            empty-view-text="暂无数据~"
            :empty-view-img-style="imgStyle"
          >
            <view class="goodsItemView">
              <view class="message-box" v-for="(item, index1) in itemList[sindex]" :key="index1">
                <view
                  class="top dis-flex flex-y-between flex-y-center"
                  @click="routeTo('/users/job/work-detail?id=' + item.id)"
                >
                  <view class="t-r dis-flex flex-y-between flex-y-center">
                    <view class="status" v-if="item.status == 1">置顶中</view>
                    <view class="tl">热控专业工程师</view>
                  </view>
                  <view class="t-l dis-flex flex-y-between flex-y-center">
                    <view class="price">7-10K/月</view>
                    <u-icon name="/static/more.png" size="28"></u-icon>
                  </view>
                </view>
                <view class="label">
                  <text class="text">贵阳</text>
                  <text class="text">3-5年 </text>
                  <text class="text">五险一金 </text>
                  <text class="text">本科</text>
                  <text class="text">绩效奖金 </text>
                  <text class="text">年终奖</text>
                </view>
                <u-line></u-line>
                <view class="bt-group dis-flex">
                  <view class="bt" v-if="item.type == 0">删除</view>
                  <view class="bt">编辑</view>
                  <view class="bt stop" v-if="item.type == 1">停止招聘</view>
                  <view class="bt res" v-if="item.type == 0">重启招聘</view>
                </view>
              </view>
            </view>
          </z-paging>
        </swiper-item>
      </swiper>
    </z-paging-swiper>
  </view>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      imgStyle: {
        width: '12rem'
      },
      show: false,
      current: 0,
      scurrent: 0,
      resStatus: '',
      tabsList: [
        {
          name: '全部',
          status: '',
          commentStatus: ''
        },
        {
          name: '招聘中',
          status: '',
          commentStatus: ''
        },
        {
          name: '已关闭',
          status: 0,
          commentStatus: ''
        }
      ],
      itemList: [[{ type: 1 }, { type: 0 }], [], []],
      order_id: ''
    }
  },
  onLoad(res) {
    this.current = Number(res.index) ? Number(res.index) : 0
    this.scurrent = Number(res.index) ? Number(res.index) : 0
  },

  onShow() {
    let self = this
    this.queryList()
  },
  methods: {
    tabsChange(index) {
      this.scurrent = index
    },
    transition(e) {
      let dx = e.detail.dx
      this.$refs.uTabs.setDx(dx)
    },
    animationfinish(e) {
      this.current = e.detail.current
      this.scurrent = e.detail.current
      this.$refs.uTabs.setFinishCurrent(e.detail.current)
      if (this.itemList[this.current].length == 0) {
        this.queryList()
      }
    },
    routeTo(url) {
      uni.navigateTo({
        url
      })
    },
    queryList(pageNo = 1, pageSize = 10) {
      this.$u
        .get('/app-api/trade/order/page', {
          pageNo,
          pageSize,
          status: this.tabsList[this.scurrent].status,
          commentStatus: this.tabsList[this.scurrent].commentStatus
        })
        .then((res) => {
          let dynamicPaging = this.scurrent > 0 ? 'paging' + this.scurrent : 'paging'
          this.$refs.paging[this.scurrent].complete(res.data.list)
        })
    }
  }
}
</script>

<style lang="scss" scoped>
page {
  height: 100%;
  background: #f0f1f2;
}
.goodsItemView {
  padding: 0 20rpx;
}
.message-box {
  height: 278rpx;
  background: #ffffff;
  border-radius: 10rpx;
  margin-bottom: 20rpx;
  padding: 30rpx 20rpx;
  .top {
    margin-bottom: 20rpx;
    .t-r {
      .status {
        height: 36rpx;
        background: #ed624f;
        border-radius: 6rpx;
        line-height: 36rpx;
        font-size: 20rpx;
        color: #ffffff;
        padding: 0 10rpx;
      }
      .tl {
        margin-left: 10rpx;
        font-size: 34rpx;
        color: #333333;
        font-weight: 600;
      }
    }
    .t-l {
      .price {
        font-size: 34rpx;
        color: #10a28f;
        font-weight: 600;
        margin-right: 4rpx;
      }
    }
  }
  .label {
    margin-bottom: 30rpx;
    .text {
      height: 36rpx;
      background: #f0f0f0;
      border-radius: 5rpx;
      font-size: 20rpx;
      color: #666666;
      line-height: 36rpx;
      padding: 0 8rpx;
      margin-right: 10rpx;
    }
  }
  .bt-group {
    margin-top: 28rpx;
    justify-content: flex-end;
    .bt {
      width: 150rpx;
      height: 60rpx;
      line-height: 60rpx;
      background: #ffffff;
      border-radius: 30rpx;
      border: 1px solid #e6e6e6;
      text-align: center;
      margin-left: 30rpx;
      font-size: 28rpx;
      color: #666666;
    }
    .stop {
      border: 1px solid #ff6f10;
      color: #ff6f10;
    }
    .res {
      border: 1px solid #10a28f;
      color: #10a28f;
    }
  }
}
</style>
